//
//  VisitorView.swift
//  WBTest
//
//  Created by 张海峰 on 2017/7/21.
//  Copyright © 2017年 张海峰. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    class func visitorView() -> VisitorView  {
         return Bundle.main.loadNibNamed("VisitorView", owner: nil, options: nil)?.first as! VisitorView    }
    //MARK:- 控件的属性
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var tipLabel: UILabel!
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var zhuCeBtn: UIButton!
    @IBOutlet weak var dengLuBtn: UIButton!
    //MARK:- 自定义属性
    func setupVisitorViewInfo(iconName :String, title : String) {
        iconView.image = UIImage.init(named: iconName)
        tipLabel.text = title
        rotationView.isHidden = true
    }
    func addRotationAnim()  {
        //1.创建动画
        rotationView.isHidden = false
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        anim.fromValue = 0
        anim.toValue = 2 * M_PI
        anim.duration = 1 //转一圈的时间
        anim.repeatCount = MAXFLOAT //无限循环
        anim.isRemovedOnCompletion = false //保证再次进来时依然旋转
        rotationView.layer.add(anim, forKey: nil)
    }
}
